#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dominion.h"

void testPlayCard(){
	int k[10] = {adventurer, council_room, feast, gardens, mine,
	       remodel, smithy, village, baron, great_hall};
	
	struct gameState *game = newGame();
	initializeGame(3, k, 10, game);
	struct gameState *test = malloc(sizeof(struct gameState));
	memcpy(test, game, sizeof(struct gameState));
	
	test->phase = 1;
	if(playCard(1, 0, 0, 0, test) == -1)
		printf("playCard(): PASS when phase is incorrect\n");
	else
		printf("playCard(): FAIL when phase is incorrect\n");
	
	test->phase = 0;
	test->numActions = 0;
	if(playCard(1, 0, 0, 0, test) == -1)
		printf("playCard(): PASS when there are no actions\n");
	else
		printf("playCard(): FAIL when there are no actions\n");
	
	test->numActions = 1;
	test->hand[test->whoseTurn][1] = adventurer-1;
	if(playCard(1, 0, 0, 0, test) == -1)
		printf("playCard(): PASS when the card is not an action card\n");
	else
		printf("playCard(): FAIL when the card is not an action card\n");

	test->hand[test->whoseTurn][1] = smithy;
	playCard(1, 0, 0, 0, test);
	if(test->handCount[test->whoseTurn] == game->handCount[test->whoseTurn]+2)
		printf("playCard(): PASS applied card effect\n");
	else
		printf("playCard(): FAIL didnt apply card effect\n");
	
	if(test->numBuys == game->numBuys)
		printf("playCard(): PASS buys not effected\n");
	else
		printf("playCard(): FAIL buys shouldn't be changed\n");
		
	if(test->numActions == game->numActions-1)
		printf("playCard(): PASS action subtracted\n");
	else
		printf("playCard(): FAIL to many actions\n");
	
	
	
}



int main(int argc, char *argv[]){
    testPlayCard();
    return 0;
}

